package com.yueka.mapper;

import com.yueka.pojo.role.Role;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface RoleMapper {
    List<Role> list(String keyword);

    Integer delete(Integer[] ids);

    @Insert("INSERT INTO role (role_name, description, permissions, create_time, update_time) VALUES (#{roleName}, #{description}, #{permissions}, #{createTime}, #{updateTime})")
    Integer insert(Role role);

    @Update("UPDATE role SET role_name = #{roleName}, description = #{description}, permissions = #{permissions}, update_time = #{updateTime} WHERE id = #{id}")
    Integer update(Role role);

    @Select("SELECT id, role_name, description, permissions, create_time, update_time FROM role WHERE id = #{id} order by update_time desc")
    Role getById(Integer id);

    @Select("SELECT id, role_name, description, permissions, create_time, update_time FROM role")
    List<Role> getAll();
}
